local jiumeng_yuanqi = fk.CreateSkill {

  name = "jiumeng_yuanqi",

  tags = {  },

}



jiumeng_yuanqi:addEffect("active", {
  name = "jiumeng_yuanqi",
  anim_type = "offensive",
  can_use = function (self, player)
    return player:getMark("@jiumeng_qi") >= 3
  end,
  interaction = function (self, player)
    local all_choices = {"jiumeng_yuanqi_3","jiumeng_yuanqi_5"}
    local choices = {"jiumeng_yuanqi_3"}
    if player:getMark("@jiumeng_qi") >= 5 then
      table.insert(choices,"jiumeng_yuanqi_5")  
    end
    return UI.ComboBox{choices = choices,all_choices  = all_choices ,detailed = true}
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  min_target_num = 0,
  max_target_num = 1,
  target_filter = function (self, player, to_select, selected, selected_cards)
    if not self.interaction.data then return end
    if self.interaction.data == "jiumeng_yuanqi_3" then
      return #selected == 0
    else
      return false  
    end
  end,
  on_use = function (self, room, effect)
    local player = effect.from
    if self.interaction.data == "jiumeng_yuanqi_3" then
      local target = effect.tos[1]
      if target then
        room:removePlayerMark(player,"@jiumeng_qi",3)
        local num = math.max(2,target:getHandcardNum())
        room:damage{
          to = target,
          damage = num,
          from = player,
          skillName = jiumeng_yuanqi.name,
        }
      end
    else
      room:removePlayerMark(player,"@jiumeng_qi",5)
      player:gainAnExtraTurn(true,jiumeng_yuanqi.name)
    end
  end,
})

return jiumeng_yuanqi